Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

child-process-promise

Package Overview
Dependencies
Maintainers
2
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

child-process-promise

Simple wrapper around the "child_process" module that makes use of promises

  • 2.2.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created

What is child-process-promise?

The 'child-process-promise' npm package is a utility that provides a promise-based interface for Node.js's child_process module. It allows you to execute shell commands and spawn new processes with the added benefit of using promises for better asynchronous control.

What are child-process-promise's main functionalities?

exec

The 'exec' function allows you to run a shell command and returns a promise that resolves with the command's output. This is useful for running simple shell commands and capturing their output.

const { exec } = require('child-process-promise');

exec('ls -la')
  .then(result => {
    console.log('stdout:', result.stdout);
    console.log('stderr:', result.stderr);
  })
  .catch(err => {
    console.error('ERROR:', err);
  });

spawn

The 'spawn' function allows you to start a new process using a given command and arguments. It returns a promise that resolves when the process completes. This is useful for more complex scenarios where you need to interact with the process's input/output streams.

const { spawn } = require('child-process-promise');

const child = spawn('ls', ['-la']);

child.childProcess.stdout.on('data', data => {
  console.log('stdout:', data.toString());
});

child.childProcess.stderr.on('data', data => {
  console.error('stderr:', data.toString());
});

child.then(() => {
  console.log('Process completed');
}).catch(err => {
  console.error('ERROR:', err);
});

Other packages similar to child-process-promise

Keywords

FAQs

Package last updated on 29 Mar 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc